// Package day_12_dp 5-62
// @Title day_12_dp
// @Description  到达右下角的路径和
// @Author  == 琳琳也叫王木木 ==  2021/9/6 15:28
// @Create  2021/9/6 15:28
package day_12_dp

func UniquePaths(m int, n int) int {
	dp := make([][]int, m) // 创建一个二维DP数组 全部初始化为1
	for i := range dp {
		dp[i] = make([]int, n)
		dp[i][0] = 1
	}
	for j := 0; j < n; j++ {
		dp[0][j] = 1
	}
	for i := 1; i < m; i++ {
		for j := 1; j < n; j++ {
			dp[i][j] = dp[i-1][j] + dp[i][j-1]
		}
	}
	return dp[m-1][n-1]
}
